package com.yyplatform.admin.platform.role.repository;

import java.util.Date;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.yyplatform.admin.platform.role.model.entity.SysCaptchaLogEntity;


/**
 * Created on 2024-09-12
 */
public interface SysCaptchaLogRepository extends
        JpaRepository<SysCaptchaLogEntity, Long>, JpaSpecificationExecutor<SysCaptchaLogEntity> {
    SysCaptchaLogEntity findByUuid(String uuid);


    @Query(
            value =
                    "SELECT * FROM sys_captcha_log WHERE 1=1 "
                            + " AND (create_time >= :beginDate AND create_time <= :endDate) ",
            countQuery =
                    "SELECT count(id) FROM sys_captcha_log WHERE 1=1 "
                            + " AND (create_time >= :beginDate AND create_time <= :endDate )",
            nativeQuery = true)
    Page<SysCaptchaLogEntity> findPage(
            @Param("beginDate") Date beginDate,
            @Param("endDate") Date endDate,
            PageRequest createTime);


}
